#include "arduino.h"
#define HEADPIN 13
#define TAILPIN 12
#define PAUSE 5000
#define FLASHCOUNTER 5000
#define REST 50

/*

  Coin Flip Program
  
  */
  


int led1 = HEADPIN;	// This is for the first led
int led2 = TAILPIN;  // This is for the second LED
long flcounter = FLASHCOUNTER; //How long to flash the leds simulating flip
long randNumber = 0; // This is the random number

// the setup routine runs once when you press reset:

void setup(void) {
  // initialize the digital pin as an output.
  pinMode(led1, OUTPUT); //initialize digital pins as output
  pinMode(led2, OUTPUT);
  Serial.begin(9600); //initialize the analog pin
  randomSeed(analogRead(0)); //initialize the random number generator by reading unknown value from analog pin 0
}

// the loop routine runs over and over again forever;

void loop(void){
if (randNumber %2 == 1){
    
	digitalWrite(led1, HIGH);  // turn the LED on HIGH is the voltage level
    digitalWrite(led2, LOW);  // turn the LED off by making the voltage LOW
                      }

    else{ 
    
    digitalWrite(led1, LOW);  // turn the the LED off by making the voltage LOW
    digitalWrite(led2, HIGH);  // turn the LED on (HIGH is the voltage level)
        }
  
delay(PAUSE);
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
delay(PAUSE);
randNumber = random(0,1333300);
flcounter = FLASHCOUNTER;
}  

void flashleds(void)
{	
	
	while(flcounter > 0){

			digitalWrite(led1,HIGH);
			digitalWrite(led2,LOW);
			delay(REST);
			digitalWrite(led1, LOW);
			digitalWrite(led2, HIGH);
			--flcounter;
			
	
		}

	
			
}
